<template>
  <div class="el-panel">
    <div class="el-panel-header" v-if="title || $slots.header " :class="{'with-border':widthBorder,'no_border':noBorder}">
      <slot name="header">
        <div class="el-panel-left">
          <h3 class="el-panel-title" v-text="title" v-if="title"></h3>
          <span class="el-panel-content" v-if="titleBtn">
            <button class="el-panel-btn" v-if="preLoanInfo.isTeleReview === 1" v-text="titleBtn" @mouseover="handleClickCon" @mouseout="handleClickCon"></button>
            <ul class="el-panel-btn-con" v-show="titleContent">
              <li class="content_li" v-for="(item, index) in preLoanInfo.teleReviewBecause" :key="index">{{item}}</li>
            </ul>
          </span>
        </div>
        <div class="el-panel-right">
          <slot name="back">
            <a href="javascript:;" v-if="back" type="danger" class="el-icon-back" round size="mini" @click="goBack">  返回 </a>
          </slot>
          <slot name="edits" v-if="edits">
            <div class="btns">
              <template v-if="!editConfig.status">
                  <el-button  v-if="edits" type="primary"  size="mini" @click="editClick">编辑</el-button>
</template>
<template v-else>
  <el-button type="success" size="mini" @click="saveClick">
    保存</el-button>
  <el-button type="danger" size="mini" @click="cancelClick">取消</el-button>
</template>
            </div>
          </slot>  
          <slot name="collapse">
            <i @click="show" v-if="collapse" class="el-collapse-item__arrow el-icon-arrow-right " :class="{'is-active':isShow}"></i>
          </slot>
        </div>
      </slot>
    </div>
    <el-collapse-transition>
      <div class="el-panel-body" v-show="isShow" :class="{'panel':panel,'no_padd': noPadd}">
          <slot name="body" v-if="$slots.body">
            暂无内容显示
          </slot>
          <slot v-else>
          </slot>
      </div>
      <div class="el-panel-footer" v-text="footer" v-if="footer">
      </div>
    </el-collapse-transition>
  </div>
</template>

<script type="text/javascript">
export default {
  name: 'elPanel',
  props: {
    widthBorder: {
      type: Boolean
    },
    panel: {
      type: Boolean
    },
    title: {
      type: String
    },
    collapse: {
      type: Boolean,
      default: false
    },
    back: {
      type: Boolean,
      default: false
    },
    edits: {
      type: Boolean,
      default: false
    },
    footer: {
      type: String
    },
    editConfig: {
      type: Object
    },
    noPadd: {
      type: String
    },
    noBorder: {
      type: String
    },
    titleBtn: {
      type: String
    },
    preLoanInfo: {
      type: Object
    }
  },
  data () {
    return {
      isShow: true,
      titleContent: false
    }
  },
  methods: {
    handleClickCon () {
      this.titleContent = !this.titleContent
    },
    goBack: function () {
      window.history.go(-1)
    },
    show () {
      this.isShow = !this.isShow
    },
    editClick () {
      this.editConfig.edit()
    },
    saveClick () {
      this.editConfig.save()
    },
    cancelClick () {
      this.editConfig.cancel()
    }
  }
}
</script>

<style scoped>
.panel {
  background: #f5f7fa;
}

.el-panel {
  box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.12), 0 0 6px 0 rgba(0, 0, 0, 0.04);
  border: 1px solid #dcdfe6;
  position: relative;
  background: #ffffff;
  margin-bottom: 10px;
  width: 100%;
  box-sizing: border-box;
}

.is-active-body {
  height: 0px;
  overflow: hidden;
}

.el-collapse-item__arrow {
  cursor: pointer;
}

.el-panel .el-collapse-item__arrow {
  line-height: 1;
  width: 14px;
  height: 14px;
  margin-left: 15px;
  text-align: center;
}

.el-panel .overlay.dark,
.overlay-wrapper .overlay.dark {
  background: rgba(0, 0, 0, 0.5);
}

.el-panel-header:before,
.el-panel-body:before,
.el-panel-footer:before,
.el-panel-header:after,
.el-panel-body:after,
.el-panel-footer:after {
  content: " ";
  display: table;
}

.el-panel-header:after,
.el-panel-body:after,
.el-panel-footer:after {
  clear: both;
}

.el-panel-header {
  color: #909399;
  background: #f5f7fa;
  border-bottom: 1px solid #e4e7ed;
  padding: 11px 15px;
  display: flex;
  align-items: center;
  /* justify-content: flex-end; */
  position: relative;
  font-size: 14px;
}
.el-panel-left{
  display: inline-block;
  font-size: 14px;
  margin: 0;
  line-height: 1;
  flex: 1;
}
.el-panel-right {
  display: flex;
  align-items: center;
}

.el-panel .btns {
  flex: 1;
}

.back {
  margin-right: 20px;
  vertical-align: middle;
}

.el-panel-header.with-border {
  border-bottom: 1px solid #f4f4f4;
}

.collapsed-box .el-panel-header.with-border {
  border-bottom: none;
}

.el-panel-header > .fa,
.el-panel-header > .glyphicon,
.el-panel-header > .ion,
.el-panel-header .el-panel-title {
  display: inline-block;
  font-size: 14px;
  margin: 0;
  line-height: 1;
  flex: 1;
}

.el-panel-header > .fa,
.el-panel-header > .glyphicon,
.el-panel-header > .ion {
  margin-right: 5px;
}

.el-panel-header > .el-panel-tools {
  position: absolute;
  right: 10px;
  top: 5px;
}

.el-panel-header > .el-panel-tools [data-toggle="tooltip"] {
  position: relative;
}

.el-panel-header > .el-panel-tools.pull-right .dropdown-menu {
  right: 0;
  left: auto;
}

.el-panel-header > .el-panel-tools .dropdown-menu > li > a {
  color: #444 !important;
}

.el-panel-body {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  border-bottom-right-radius: 3px;
  border-bottom-left-radius: 3px;
  padding: 10px;
}

.el-panel-footer {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  border-bottom-right-radius: 3px;
  border-bottom-left-radius: 3px;
  border-top: 1px solid #f4f4f4;
  padding: 10px;
  background-color: #ffffff;
}

.is-active-body {
  padding: 0;
  height: 0px;
  overflow: hidden;
}
.no_padd{
  padding: 0
}
.no_border{
  border-bottom: 0;
}
.el-panel-btn{
  border: 0;
  padding: 5px 10px;
  outline:none;
  background-color: #FFCE02;
}
.content_li{
  background-color: #F2F2F2;
  padding: 10px 10px;
  color: #000;
}
.el-panel-content{
  display: inline-block;
}
.el-panel-btn-con{
  z-index: 999;
  position: absolute;
}
</style>
